//
//  MainTabbarController.swift
//  Amicool
//
//  Created by Mac  on 2017/6/5.
//  Copyright © 2017年 Mac . All rights reserved.
//

import UIKit

class MainTabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //从故事版中取得视频主页的对应的导航控制器即可
        let videoStoryboard = UIStoryboard(name: "Video", bundle: nil)
        
        let videoNavController = videoStoryboard.instantiateViewController(withIdentifier: "videonav")
        
        let me = MyViewController()
        self.viewControllers = [videoNavController,me]
        
        let tabBarItemTitles:[String] = ["视频","我"]
        let tabBarItemImages:[String] = ["video","me"]
        
        //设置tabBar
        let tabBar = self.tabBar
        self.tabBar.frame = CGRect(x: tabBar.frame.minX, y: tabBar.frame.minY, width: tabBar.frame.width, height: 50)
        var index = 0
        for item in self.tabBar.items!{
            //设置标题
            item.title = tabBarItemTitles[index]
            //设置图标
            //已选择图标
            let selectedimage = UIImage(named: String(format: "%@.png", tabBarItemImages[index]))?.scaleImageToSize(CGSize(width: 25, height: 25))
            //未选择图+标
            let unselectedimage = UIImage(named: String(format: "%@-2.png", tabBarItemImages[index]))?.scaleImageToSize(CGSize(width: 25, height: 25))
                item.image = selectedimage
            item.selectedImage = unselectedimage
            
            index += 1
        }

          }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
